<ossec_config>
  <client>
    <server>
      <address>{{ os_ossec_managers.address | list | random(seed=ansible_hostname) }}</address>
      <port>{{ os_ossec_managers.port }}</port>
      <protocol>{{ os_ossec_managers.protocol }}</protocol>
      <max_retries>5</max_retries>
      <retry_interval>5</retry_interval>
    </server>
{% if ossec_notify_time is not none and wazuh_time_reconnect is not none %}
    <notify_time>{{ os_ossec_agent_config.notify_time }}</notify_time>
    <time-reconnect>{{ os_ossec_agent_config.time_reconnect }}</time-reconnect>
{% endif %}
    <auto_restart>{{ os_ossec_agent_config.auto_restart }}</auto_restart>
    <crypto_method>{{ os_ossec_agent_config.crypto_method }}</crypto_method>
  </client>

  <logging>
    <log_format>{{ os_ossec_agent_config.log_format }}</log_format>
  </logging>

  <active-response>
    <disabled>{{ os_ossec_agent_config.active_response | default('no') }}</disabled>
    <ca_store>{% if ansible_os_family == "Windows" %}wpk_root.pem{% else %}/var/ossec/etc/wpk_root.pem{% endif %}</ca_store>
    <ca_verification>yes</ca_verification>
  </active-response>

  <labels>
    <label key="project">{{ group_names[0] | title | regex_replace("_", "-") }}</label>
    <label key="group">{{ group_names[-1] | title | regex_replace("_", "-") }}</label>
    <label key="environment">{{ environments | upper }}</label>
    <label key="datacenter">{{ datacenter | lower }}</label>
    <label key="domain">{{ domain | lower }}</label>
{% if tags is defined %}
{% for key,value in tags.iteritems() %}
    <label key="{{ key }}">{{ value }}</label>
{% endfor %}
{% endif %}
  </labels>

</ossec_config>
